package com.steven.realServer.controller;

import com.alibaba.fastjson.JSONObject;
import com.steven.realServer.pojo.UserDetail;
import com.steven.realServer.service.IdentifyService;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class IdentifyController {

    @Autowired
    private IdentifyService service;

    @PostMapping("/identify/schoolList")
    public JSONObject schoolList(String schoolName) {
        return service.searchSchool(schoolName);
    }

    @PostMapping("/identify/addUserDetail")
    public JSONObject addUserDetail(UserDetail detail) {
        return service.addUserDetail(detail);
    }

    @PostMapping("/identify/queryStatus")
    public JSONObject queryIdentifyStatus(Long uid) {
        return service.queryUserIdentifyStatus(uid);
    }

    @PostMapping("/identify/updateStatus")
    public JSONObject updateIdentify(@RequestHeader("uid") Long uid, @NotNull Long normalUser, @NotNull boolean canPass) {
        return service.updateUserIdentify(uid, normalUser, canPass);
    }

    @PostMapping("/identify/upload")
    public JSONObject uploadStudent(MultipartFile image, @RequestHeader("uid") Long uid) throws IOException {
        return service.uploadStudent(image, uid);
    }

    @PostMapping("/info/userName")
    public JSONObject queryUserName(@RequestHeader("uid") Long uid) {
        return service.queryUserName(uid);
    }

    @PostMapping("/identify/queryToBeConfirm")
    public JSONObject queryToBeConfirm(@RequestHeader("uid") Long uid) {
        return service.queryToBeConfirm(uid);
    }
}
